//
//  LS_PublishAdTableViewCell.m
//  breadPro
//
//  Created by 刘文超 on 2019/7/10.
//  Copyright © 2019 刘文超. All rights reserved.
//

#import "LS_PublishAdTableViewCell.h"
#import "LS_FindViewModel.h"
@interface LS_PublishAdTableViewCell()
@property(nonatomic,strong)UIImageView *imageAdView;
@property(nonatomic,strong)UITapGestureRecognizer *tap;
@end
@implementation LS_PublishAdTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
     
    }return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.imageAdView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.centerY.offset(0);
        make.height.offset(80);
    }];
}
#pragma mark -
#pragma mark --绑定View的数据
- (void)bindViewModel:(id)viewModel withParams:(NSDictionary *)params
{
    NSLog(@"viewModel----%@------params-----%@",viewModel,params);
//    NSDictionary *dict =(NSDictionary *)viewModel;
    LS_FindViewModel *model = viewModel;
    [self.imageAdView sd_setImageWithURL:[NSURL URLWithString:kFORMAT(@"%@",model.advertise_pic[@"imgurl"])] placeholderImage:LS_Getimage(@"erweima")];
    [self.imageAdView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset([kFORMAT(@"%@",model.advertise_pic[@"imgheight"]) floatValue]);
    }];
    
    [self.tap.rac_gestureSignal subscribeNext:^(id x) {
         [model.didPublishMessageCommand execute:x];
    }];
}
-(UIImageView *)imageAdView
{
    return LS_LAZY(_imageAdView, ({
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.userInteractionEnabled = YES;
        [self.contentView addSubview:imageView];
        [imageView addGestureRecognizer:self.tap];
        imageView;
    }));
}
-(UITapGestureRecognizer *)tap
{
    return LS_LAZY(_tap, ({
        UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc]init];
        tap;
    }));
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end
